package com.briup.sms.utils;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;
import java.util.Map;

public class JWTUtils {
    private static final String signingKey="briup";
    private static final long expiration=30*60*1000;
    public static  String  generator(Map<String,Object> map){
        String token = Jwts.builder()
                .addClaims(map)
                .signWith(SignatureAlgorithm.HS256, signingKey)
                .setExpiration(new Date(System.currentTimeMillis() + expiration))
                .compact();
        return  token;

    }
    public static  Object parse(String token){
        Object body = Jwts.parser()
                .setSigningKey(signingKey)
                .parse(token)
                .getBody();
        return body;

    }
}
